#!/usr/bin/env python
#coding:utf-8

import threading
import dosomework

from Tkinter import *
from tkFileDialog import askopenfilename
import unicodedata

root = Tk();

var = StringVar()
var.set("1")
naam = []

root.title('Bio-Inf Toolkit')  

def callyourscript1(filename,filetype):
    import os
    cmd='%s %s %s' % (filename,filename,filetype)
    ret=os.system(cmd)
    if ret:
        print 'call script fail'
    else:
        print 'call script ok'    

def callyourscript2(filename,filetype):
    import subprocess

    cmd=[filename,filename,filetype]    
    ret=subprocess.call(cmd,shell=True)
    if ret:
        print 'call script fail'
    else:
        print 'call script ok'

def openfile():
    een = askopenfilename()
    twee = unicodedata.normalize("NFKD",een).encode("ascii","ignore")
    naam.insert(0,twee)

def doOne():
    return var.get()

def ClickToRun():
    #print var.get()
    naam2 = ','.join(str(n) for n in naam)
    print naam2
    
    #method 1
    th=threading.Thread(target=dosomework.workfunc1,name='thworkfunc1',args=(naam2,var.get()))
    th.start()
    
    #method 2
    #callyourscript1(naam2,var.get())
    
    #method 3
    #callyourscript2(naam2,var.get())
    
    return naam2

Label(root,text='Bio-Inf \n TOOLKIT').pack(pady=10)
Label(root, text="Klik op de knop om een file te kiezen ").pack(pady=10)
Button(root, text='Choose File', command=openfile) .pack(side=TOP)


Label(root, text="Wat voor een type file is het? ").pack(pady=10)
Radiobutton(root, text="GenBank", value="GenBank", variable=var, command = doOne).pack()
Radiobutton(root, text="Fasta", value="Fasta", variable=var, command = doOne).pack()

Button(root, text='ClickToRun', command=ClickToRun) .pack(side=BOTTOM)

root.mainloop()

#print naam2
print var.get()

